﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CompanyOrder.aspx.cs" Inherits="NJL.WebUsers.CompanyOrder" %>

<%@ Register Src="Controls/WUCHeader1.ascx" TagName="WUCHeader1" TagPrefix="uc1" %>
<%@ Register Src="Controls/WUCFooter1.ascx" TagName="WUCFooter1" TagPrefix="uc2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>订单确认-农家乐网</title>
    <link href="/Styles/base1.css" rel="stylesheet" type="text/css" />
    <link href="/Styles/manage.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="/Scripts/md5.js" type="text/javascript"></script>
    <script src="/Scripts/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        //自动计算
        autoCount = function () {
            var value = $('#spanTicketCount').html();
            var vLocalPrice = $('#spanLocalPrice').html();
            $('#spanAllPrice').html(vLocalPrice * value);
            $('#hidTotalPrice').val(vLocalPrice * value);
        }

        //订票数据两边处理
        checkTicketCount = function () {
            var reg = /^([1-9]{1}[0-9]{1})|([1-9]{1})$/;
            var value = $('#txtTicketCount').val();

            if (value != '') {
                if (!reg.test(value)) {
                    $('#txtTicketCount').val('');
                }
            }
            value = $('#txtTicketCount').val();
            if (value == '') {
                $('#spanTicketCount').html(1);

                $('#spanAlertTicketCount').show();
            }
            else {
                $('#spanTicketCount').html(value);
                $('#spanAlertTicketCount').hide();
            }

            //计算
            autoCount();
        }

        //提交个人信息认证
        checkPersonInfo = function () {
            var vReturnValue = true;

            var vSelectPick = $('#selPick').val();
            var vSelectBook = $('#selBook').val();

            var regDate = /^((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)$/;
            var regName = /^(\w|[\u4E00-\u9FA5]){1,20}$/;
            var regMobile = /^1[3,4,5,8][\d]{9}$/;
            var regEmail = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;

            var vPickName = $('#txtPickName').val();
            var vPickMobile = $('#txtPickMobile').val();
            var vPickEmail = $('#txtPickEmail').val();

            var vBookName = $('#txtBookName').val();
            var vBookMobile = $('#txtBookMobile').val();
            var vBookEmail = $('#txtBookEmail').val();


            //出游日期
            var vTripDate = $('#txtTripDate').val();
            if (regDate.test(vTripDate)) {

                var dtime = new Date();

                //如果预定今天的票
                //alert(dtime.getVarDate());
                var vYearString = dtime.getFullYear();
                var vMonthString = (dtime.getMonth() + 1) < 10 ? '0' + (dtime.getMonth() + 1) : (dtime.getMonth() + 1);
                var vDayString = (dtime.getDate() + 0) < 10 ? '0' + (dtime.getDate() + 0) : (dtime.getDate() + 0);
                var vDateString = vYearString + '-' + vMonthString + '-' + vDayString;
                //                alert(vDateString);
                //                alert(vTripDate);
                if (vDateString == vTripDate) {
                    var vHourString = dtime.getHours() < 10 ? '0' + (dtime.getHours() + 0) : (dtime.getHours() + 0);
                    var vMinuteString = dtime.getMinutes() < 10 ? '0' + (dtime.getMinutes() + 0) : (dtime.getMinutes() + 0);
                    var vTimeString = vHourString + ':' + vMinuteString;
                    //alert(vTimeString);
                    //alert($('#spanThatDayDeadline').html());
                    if (vTimeString > $('#spanThatDayDeadline').html()) {
                        alert('不能预定今天的了');
                        $('#spanTripDateLabel').show();
                        vReturnValue = false;
                    }
                    else {
                        $('#spanTripDateLabel').hide();
                    }
                }
                //
                if (vDateString > vTripDate) {
                    $('#spanTripDateLabel').show();
                    vReturnValue = false;
                }
                else {
                    $('#spanTripDateLabel').hide();
                }
            }
            else {
                $('#spanTripDateLabel').show();
                vReturnValue = false;
            }

            //预定票数量
            var regTicketCount = /^([1-9]{1}[0-9]{1})|([1-9]{1})$/;
            var value = $('#txtTicketCount').val();
            if (regTicketCount.test(value)) {
                $('#spanAlertTicketCount').hide();
            }
            else {
                $('#spanAlertTicketCount').show();
                vReturnValue = false;
            }
            //预定人信息
            if (regName.test(vPickName)) {
                $('#spanPickName').hide();
            }
            else {
                $('#spanPickName').show();
                vReturnValue = false;
            }

            if (vSelectPick == '1') {
                if (regMobile.test(vPickMobile)) {
                    $('#spanPickMobile').hide();
                }
                else {
                    $('#spanPickMobile').show();
                    vReturnValue = false;
                }
            }
            else {
                if (regEmail.test(vPickEmail)) {
                    $('#spanPickEmail').hide();
                }
                else {
                    $('#spanPickEmail').show();
                    vReturnValue = false;
                }
            }

            if (regName.test(vBookName)) {
                $('#spanBookName').hide();
            }
            else {
                $('#spanBookName').show();
                vReturnValue = false;
            }

            if (vSelectBook == '1') {
                if (regMobile.test(vBookMobile)) {
                    $('#spanBookMobile').hide();
                }
                else {
                    $('#spanBookMobile').show();
                    vReturnValue = false;
                }
            }
            else {
                if (regEmail.test(vBookEmail)) {
                    $('#spanBookEmail').hide();
                }
                else {
                    $('#spanBookEmail').show();
                    vReturnValue = false;
                }
            }

            return vReturnValue;
        }

        changeConnect = function () {
            var vSelectPick = $('#selPick').val();
            var vSelectBook = $('#selBook').val();

            if (vSelectPick == '1') {
                $('#spanPickMobileLabel').show();
                $('#spanPickEmailLabel').hide();
                $('#spanPickEmail').hide();
            }
            else {
                $('#spanPickMobileLabel').hide();
                $('#spanPickEmailLabel').show();
                $('#spanPickMobile').hide();
            }

            if (vSelectBook == '1') {
                $('#spanBookMobileLabel').show();
                $('#spanBookEmailLabel').hide();
                $('#spanBookEmail').hide();
            }
            else {
                $('#spanBookMobileLabel').hide();
                $('#spanBookEmailLabel').show();
                $('#spanBookMobile').hide();
            }
        }

        //单独校验出游日期
        checkTripDate = function () {
            var vReturnValue = true;
            var regDate = /^((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)$/;
            //出游日期
            var vTripDate = $('#txtTripDate').val();
            if (regDate.test(vTripDate)) {

                var dtime = new Date();

                //如果预定今天的票
                //alert(dtime.getVarDate());
                var vYearString = dtime.getFullYear();
                var vMonthString = (dtime.getMonth() + 1) < 10 ? '0' + (dtime.getMonth() + 1) : (dtime.getMonth() + 1);
                var vDayString = (dtime.getDate() + 0) < 10 ? '0' + (dtime.getDate() + 0) : (dtime.getDate() + 0);
                var vDateString = vYearString + '-' + vMonthString + '-' + vDayString;

                if (vDateString == vTripDate) {
                    var vHourString = dtime.getHours() < 10 ? '0' + (dtime.getHours() + 0) : (dtime.getHours() + 0);
                    var vMinuteString = dtime.getMinutes() < 10 ? '0' + (dtime.getMinutes() + 0) : (dtime.getMinutes() + 0);
                    var vTimeString = vHourString + ':' + vMinuteString;

                    if (vTimeString > $('#spanThatDayDeadline').html()) {
                        alert('不能预定今天的了');
                        $('#spanTripDateLabel').show();
                        vReturnValue = false;
                    }
                    else {
                        $('#spanTripDateLabel').hide();
                    }
                }
                //
                if (vDateString > vTripDate) {
                    $('#spanTripDateLabel').show();
                    vReturnValue = false;
                }
                else {
                    $('#spanTripDateLabel').hide();
                }
            }
            else {
                $('#spanTripDateLabel').show();
                vReturnValue = false;
            }
            return vReturnValue;
        }

        //单独校验订票数量
        checkTicketCountAlert = function () {
            var vReturnValue = true;
            //预定票数量
            var regTicketCount = /^([1-9]{1}[0-9]{1})|([1-9]{1})$/;
            var value = $('#txtTicketCount').val();
            if (regTicketCount.test(value)) {
                $('#spanAlertTicketCount').hide();
            }
            else {
                $('#spanAlertTicketCount').show();
                vReturnValue = false;
            }
            return vReturnValue;
        }

        //单独校验-取票人姓名
        checkPickName = function () {
            var vReturnValue = true;

            var vSelectPick = $('#selPick').val();
            var vSelectBook = $('#selBook').val();

            var regName = /^(\w|[\u4E00-\u9FA5]){1,20}$/;
            var regMobile = /^1[3,4,5,8][\d]{9}$/;
            var regEmail = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;

            var vPickName = $('#txtPickName').val();
            var vPickMobile = $('#txtPickMobile').val();
            var vPickEmail = $('#txtPickEmail').val();

            var vBookName = $('#txtBookName').val();
            var vBookMobile = $('#txtBookMobile').val();
            var vBookEmail = $('#txtBookEmail').val();
            //预定人信息-取票人姓名
            if (regName.test(vPickName)) {
                $('#spanPickName').hide();
            }
            else {
                $('#spanPickName').show();
                vReturnValue = false;
            }
            return vReturnValue;
        }
        //单独校验-取票人信息：手机、电话
        checkPickMobileEmail = function () {
            var vReturnValue = true;

            var vSelectPick = $('#selPick').val();
            var vSelectBook = $('#selBook').val();

            var regName = /^(\w|[\u4E00-\u9FA5]){1,20}$/;
            var regMobile = /^1[3,4,5,8][\d]{9}$/;
            var regEmail = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;

            var vPickName = $('#txtPickName').val();
            var vPickMobile = $('#txtPickMobile').val();
            var vPickEmail = $('#txtPickEmail').val();

            var vBookName = $('#txtBookName').val();
            var vBookMobile = $('#txtBookMobile').val();
            var vBookEmail = $('#txtBookEmail').val();
            //取票人信息：手机、电话
            if (vSelectPick == '1') {
                if (regMobile.test(vPickMobile)) {
                    $('#spanPickMobile').hide();
                }
                else {
                    $('#spanPickMobile').show();
                    vReturnValue = false;
                }
            }
            else {
                if (regEmail.test(vPickEmail)) {
                    $('#spanPickEmail').hide();
                }
                else {
                    $('#spanPickEmail').show();
                    vReturnValue = false;
                }
            }

            return vReturnValue;
        }
        //单独校验-预定人：名称
        checkBookName = function () {
            var vReturnValue = true;

            var vSelectPick = $('#selPick').val();
            var vSelectBook = $('#selBook').val();

            var regName = /^(\w|[\u4E00-\u9FA5]){1,20}$/;
            var regMobile = /^1[3,4,5,8][\d]{9}$/;
            var regEmail = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;

            var vPickName = $('#txtPickName').val();
            var vPickMobile = $('#txtPickMobile').val();
            var vPickEmail = $('#txtPickEmail').val();

            var vBookName = $('#txtBookName').val();
            var vBookMobile = $('#txtBookMobile').val();
            var vBookEmail = $('#txtBookEmail').val();
            //预定人名称

            if (regName.test(vBookName)) {
                $('#spanBookName').hide();
            }
            else {
                $('#spanBookName').show();
                vReturnValue = false;
            }

            return vReturnValue;
        }
        //单独校验-预定人：手机、邮箱、
        checkBookMobileEmail = function () {
            var vReturnValue = true;

            var vSelectPick = $('#selPick').val();
            var vSelectBook = $('#selBook').val();

            var regName = /^(\w|[\u4E00-\u9FA5]){1,20}$/;
            var regMobile = /^1[3,4,5,8][\d]{9}$/;
            var regEmail = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;

            var vPickName = $('#txtPickName').val();
            var vPickMobile = $('#txtPickMobile').val();
            var vPickEmail = $('#txtPickEmail').val();

            var vBookName = $('#txtBookName').val();
            var vBookMobile = $('#txtBookMobile').val();
            var vBookEmail = $('#txtBookEmail').val();
            //预定人：手机、邮箱、

            if (vSelectBook == '1') {
                if (regMobile.test(vBookMobile)) {
                    $('#spanBookMobile').hide();
                }
                else {
                    $('#spanBookMobile').show();
                    vReturnValue = false;
                }
            }
            else {
                if (regEmail.test(vBookEmail)) {
                    $('#spanBookEmail').hide();
                }
                else {
                    $('#spanBookEmail').show();
                    vReturnValue = false;
                }
            }
            return vReturnValue;
        }
        function copyUserInfo() {
            $('#<%=txtBookName.ClientID %>').val($('#<%=txtPickName.ClientID %>').val());
            $('#<%=txtBookMobile.ClientID %>').val($('#<%=txtPickMobile.ClientID %>').val());
            $('#<%=txtBookEmail.ClientID %>').val($('#<%=txtPickEmail.ClientID %>').val());
        }
        function copyqprUserInfo() {
            $('#<%=txtPickName.ClientID %>').val($('#<%=txtBookName.ClientID %>').val());
            $('#<%=txtPickMobile.ClientID %>').val($('#<%=txtBookMobile.ClientID %>').val());
            $('#<%=txtPickEmail.ClientID %>').val($('#<%=txtBookEmail.ClientID %>').val());
        }
    </script>
</head>
<body onload="javascript:autoCount();">
    <form id="form1" runat="server">
    <input type="hidden" id="hidTotalPrice" runat="server" />
    <uc1:WUCHeader1 ID="WUCHeader11" runat="server" />
    <div class="cleanFlex managecont">
        <div class="m_top_10">
        </div>
        <!--订单流程-->
        <%
            if (MODEL_BOOK.NJL_CS_BOOK_PAY_TYPE_CODE == "2")
            {
        %>
        <div class="orderMenu">
            <ul class="menuInfo03_02">
                <li class="menu_not" style="width: 334px;">
                    <h2>
                        1、搜索选择农家乐或度假山庄</h2>
                </li>
                <li class="menu_at" style="width: 334px;">
                    <h2>
                        2、填写订单信息</h2>
                </li>
                <li class="menu_sel" style="width: 335px;">
                    <h2>
                        3、预订成功</h2>
                </li>
            </ul>
        </div>
        <%
            }
            else
            { 
        %>
        <div class="orderMenu">
            <ul class="menuInfo04_02">
                <li class="menu_not" style="width: 250px;">
                    <h2>
                        1、搜索选择农家乐或度假山庄</h2>
                </li>
                <li class="menu_at" style="width: 251px;">
                    <h2>
                        2、填写订单信息</h2>
                </li>
                <li class="menu_sel" style="width: 251px;">
                    <h2>
                        3、在线支付</h2>
                </li>
                <li class="menu_sel" style="width: 251px;">
                    <h2>
                        4、预订成功</h2>
                </li>
            </ul>
        </div>
        <%
            }
        %>
        <div class="reg" style="height: 700px;">
            <div class="m_top_10">
            </div>
            <div style="width: 98%; border: 1px solid #dbf4d0; margin: 0 auto; background: #fff;">
                <table style="width: 85%; margin: 0 auto;" class="tab">
                    <tr>
                        <td style="width: 15%;" class="left">
                            <strong>预订门票:</strong>
                        </td>
                        <td colspan="2">
                            <a target="_blank" href="/shangpu/<%=MODEL_COMPANY.ID %>-index.html">
                                <%=MODEL_COMPANY.COMPANY_NAME%></a>-<%=MODEL_BOOK.BOOK_NAME %>
                        </td>
                    </tr>
                    <tr>
                        <td class="left">
                            <strong>游玩日期:</strong>
                        </td>
                        <td colspan="2">
                            <asp:TextBox ID="txtTripDate" runat="server" CssClass="input" onblur="checkTripDate()"
                                onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"></asp:TextBox>
                            <span id="spanTripDateLabel" style="display: none;" class="prompt">请选择日期</span>
                            您可于<span id="spanThatDayDeadline"><%=MODEL_BOOK.THAT_DAY_DEADLINE.Value.ToString("HH:mm") %></span>之前预订当天门票
                        </td>
                    </tr>
                    <tr>
                        <td class="left">
                            <strong>预订数量:</strong>
                        </td>
                        <td>
                            <asp:TextBox ID="txtTicketCount" CssClass="input" Width="30" MaxLength="2" Text="1"
                                onblur="checkTicketCountAlert()" onkeydown='javascript:checkTicketCount()' onkeyup='javascript:checkTicketCount()'
                                onchange="javascript:checkTicketCount()" runat="server"></asp:TextBox><span id="spanAlertTicketCount"
                                    style="display: none">请输入1-99的数字</span>
                        </td>
                        <td class="book_total">
                            <span id="spanTicketCount">1</span> X <span id="spanLocalPrice">
                                <%=MODEL_BOOK.LOCAL_PRICE.Value.ToString("0") %></span>元
                        </td>
                    </tr>
                    <tr class="bottom">
                        <td>
                        </td>
                        <td>
                            可获得<strong class="font14 orange04"><%=MODEL_BOOK.BACK_PRICE.Value.ToString("0") %></strong>元点评奖金
                        </td>
                        <td class="book_total">
                            <span>总价:<span id="spanAllPrice"></span>元</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="m_top_20">
            </div>
            <div style="width: 98%; border: 1px solid #dbf4d0; margin: 0 auto; background: #fff;">
                <table style="width: 95%; margin: 0 auto;" class="tab">
                    <tr>
                        <td style="width: 18%" class="left">
                            <span style="color: #ff0000">*</span><strong>取票人姓名:</strong>
                        </td>
                        <td>
                            <asp:TextBox ID="txtPickName" CssClass="input" runat="server" onblur="checkPickName()"></asp:TextBox>
                            <span id="spanPickName" style="display: none" class="prompt">请输入1-10个汉字或英文</span><a
                                href="javascript:copyqprUserInfo()">[点此复制预订人信息]</a>
                        </td>
                    </tr>
                    <tr>
                        <td class="left">
                            <span id="spanPickMobileLabel" style="color: #ff0000">*</span><strong>取票人手机号码:</strong>
                        </td>
                        <td>
                            <select id="selPick" onchange="javascript:changeConnect()">
                                <option value="1">大陆地区手机</option>
                                <option value="0">非大陆地区手机</option>
                            </select>
                            <asp:TextBox ID="txtPickMobile" MaxLength="11" CssClass="input" runat="server" onblur="checkPickMobileEmail()"></asp:TextBox>
                            <span id="spanPickMobile" style="display: none" class="prompt">手机号码以13、14、15或18开头的11位数字，请正确输入联系人手机号码</span>
                        </td>
                    </tr>
                    <tr style="display: none">
                        <td class="left">
                            <span id="spanPickEmailLabel" style="color: #ff0000; display: none;">*</span><strong>取票人电子邮箱:</strong>
                        </td>
                        <td>
                            <span style="float: left">
                                <asp:TextBox ID="txtPickEmail" MaxLength="200" CssClass="input" runat="server" onblur="checkPickMobileEmail()"
                                    Style="width: 280px"></asp:TextBox>
                                <span id="spanPickEmail" style="display: none" class="prompt">请输入正确格式的邮件地址</span></span>
                        </td>
                    </tr>
                    <tr>
                        <td class="left">
                            <span style="color: #ff0000">*</span><strong>预订人姓名:</strong>
                        </td>
                        <td>
                            <asp:TextBox ID="txtBookName" CssClass="input" runat="server" onblur="checkBookName()"></asp:TextBox>
                            <span id="spanBookName" style="display: none" class="prompt">请输入1-10个汉字或英文</span><a
                                href="javascript:copyUserInfo()">[点此复制取票人信息]</a>
                        </td>
                    </tr>
                    <tr>
                        <td class="left">
                            <span id="spanBookMobileLabel" style="color: #ff0000">*</span><strong>预订人手机号码:</strong>
                        </td>
                        <td>
                            <select id="selBook" onchange="javascript:changeConnect()">
                                <option value="1">大陆地区手机</option>
                                <option value="0">非大陆地区手机</option>
                            </select>
                            <asp:TextBox ID="txtBookMobile" MaxLength="11" CssClass="input" runat="server" onblur="checkBookMobileEmail()"></asp:TextBox>
                            <span id="spanBookMobile" style="display: none" class="prompt">手机号码以13、14、15或18开头的11位数字，请正确输入联系人手机号码</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="left">
                            <span id="spanBookEmailLabel" style="color: #ff0000; display: none;">*</span><strong>预定人电子邮箱:</strong>
                        </td>
                        <td>
                            <span style="float: left">
                                <asp:TextBox ID="txtBookEmail" MaxLength="200" CssClass="input" runat="server" onblur="checkBookMobileEmail()"
                                    Style="width: 280px"></asp:TextBox>
                                <span id="spanBookEmail" style="display: none" class="prompt">请输入正确格式的邮件地址</span></span>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="m_top_20">
            </div>
            <div style="width: 98%;" class="centeralign">
                <asp:Button ID="btnSubmit" runat="server" CssClass="submit_btn" OnClientClick="return checkPersonInfo();"
                    OnClick="btnSubmit_Click" />
            </div>
            <div class="m_top_20">
            </div>
            <div style="width: 95%; border: 1px solid #dbf4d0; margin: 0 auto; padding: 15px;
                background: #fff;">
                <%=MODEL_BOOK.TICKET_NOTICE %>
            </div>
            <div style="width: 95%; border: 1px solid #dbf4d0; margin: 0 auto; margin-top: 5px; padding: 15px; background: #fff;">
                发票说明：网络预定门票，非在线支付，农家乐网不提供发票
            </div>
            <div class="cleanFlex">
            </div>
        </div>
    </div>
    <uc2:WUCFooter1 ID="WUCFooter11" runat="server" />
    </form>
</body>
</html>
